﻿<UserControl x:Class="TextFileReaderModule.Views.TextFileReaderView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:views="clr-namespace:TextFileReaderModule.Views"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:InteractionRequest="http://www.codeplex.com/prism"
             xmlns:views1="clr-namespace:Mitosoft.Definitions.Views;assembly=Mitosoft.Definitions"
             mc:Ignorable="d" >
    
    <i:Interaction.Triggers>
        <InteractionRequest:InteractionRequestTrigger SourceObject="{Binding SaveCommentsDialogRequest, Mode=OneWay}">
            <InteractionRequest:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                <InteractionRequest:PopupWindowAction.WindowContent>
                    <views:SaveCommentsDialogView />
                </InteractionRequest:PopupWindowAction.WindowContent>
            </InteractionRequest:PopupWindowAction>
        </InteractionRequest:InteractionRequestTrigger>
        <InteractionRequest:InteractionRequestTrigger SourceObject="{Binding GotoLineNumberDialogRequest, Mode=OneWay}">
            <InteractionRequest:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                <InteractionRequest:PopupWindowAction.WindowContent>
                    <views:GotoLineNumberDialogView />
                </InteractionRequest:PopupWindowAction.WindowContent>
            </InteractionRequest:PopupWindowAction>
        </InteractionRequest:InteractionRequestTrigger>
        <InteractionRequest:InteractionRequestTrigger SourceObject="{Binding FilesSelectionDialogRequest, Mode=OneWay}">
            <InteractionRequest:PopupWindowAction IsModal="True" CenterOverAssociatedObject="True">
                <InteractionRequest:PopupWindowAction.WindowContent>
                    <views1:FilesSelectionDialogView />
                </InteractionRequest:PopupWindowAction.WindowContent>
            </InteractionRequest:PopupWindowAction>
        </InteractionRequest:InteractionRequestTrigger>
    </i:Interaction.Triggers>
    
    <Grid Background="AliceBlue">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <StackPanel
            Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3"
            Orientation="Horizontal"
            >
            <Menu>
                <MenuItem Header="File">
                    <MenuItem Header="Open..." Command="{Binding SelectLogFileCommand}" />
                    <MenuItem Header="Save comments" Command="{Binding SaveCommentsCommand}" IsEnabled="{Binding SaveCommentsCommandIsEnabled}" />
                </MenuItem>
                <MenuItem Header="Edit">
                </MenuItem>
                <MenuItem Header="Search">
                    <MenuItem Header="Go to..." Command="{Binding GotoLogLineCommand}" />
                </MenuItem>
            </Menu>
        </StackPanel>
        
        <Label
            Grid.Row="1" Grid.Column="0"
            Content="Log file:" />

        <TextBox Text="{Binding OneFileDataManager.LogFile, Mode=TwoWay}"
            Grid.Row="1" Grid.Column="1"
            />
        
        <Button 
            Grid.Row="1" Grid.Column="2"
            Content="..."
            Command="{Binding SelectLogFileCommand}"
            />
        
        <views:TextFileContentView
            ItemsSource="{Binding Path=MultipleFilesDataManager.CachedCollectionBlockDataProvider}"
            ScrollSelectedItemIntoView="{Binding ScrollSelectedTextLineIntoView, Mode=TwoWay}"
            SelectedItem="{Binding Path=SelectedTextLine, Mode=TwoWay}"
            Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"
        />
        
    </Grid>
    
</UserControl>
